<template>
	<w-container id="container" :style="getBgStyle" :loading="loading">
		<w-navbar  bgColor="transparent" :placeholder="false" leftIcon="arrow-left-back" :leftIconSize="32" >
			<template #right>
				<view class="flex flex-ai-center">
					<view class="else-actoon-btn flex flex-ai-center flex-js-center" @click="$u.route('/pages/lottery/record',{id:info.id})">{{handleLang('中奖记录')}}</view>
					<!-- <view class="else-actoon-btn flex flex-ai-center flex-js-center" @click.active="$u.route('/pages/lottery/rule',{id:info.id})">{{handleLang('规则')}}</view> -->
				</view>
			</template>
		</w-navbar>
		<image @click.active="$u.route('/pages/lottery/rule',{id:info.id})" :src="$originOssUrl + '/static/cj/9.png'" class="rule-box"></image>
		<!-- <lotteryBox :info="info" @refresh="getDetails"></lotteryBox> -->
		<lotteryBoxNew :info="info" @refresh="getDetails" />
		<!-- 抽奖消耗藏品 -->
		<block v-if="info.type==20">
			<!-- <view class="line"></view> -->
			<view class="plr-15 ptb-26">
				<view class="list">
					<view class="title">{{handleLang('拥有以下藏品可获得相应的抽奖次数')}} <text style="color: #FF2449;">{{handleLang('(已寄售除外)')}}</text> </view>
					<view class="con">
						<view class="item mb-16  pb-8 bg-color-item br-8" v-for="(item,idx) in info.collection_json" :key="idx"
							@click="$u.route('/pages/market/marketGoodsList',{id:item.id,goodsType:2})">
							<view class="img">
								<w-image :src="item.collectionInfo.main_image" width="148" height="188" br='8'></w-image>
								<!-- <view class="num">{{ item.collectionInfo.total_num }}</view> -->
							</view>
							<view class="pa-8">
								<view class="font-size-14 text-overflow font-color-textPrimary">{{ item.collectionInfo.name&&handleLang(item.collectionInfo.name) }}</view>
								<view class="flex flex-ai-center flex-js-sb mt-8">
									<w-tag name='限量' :value='item.collectionInfo.total_num+"份"'></w-tag>
									<text class="font-size-16 font-w-500 font-color-price">¥{{ item.collectionInfo.price }}</text>
								</view>
							</view>
						</view>
					</view>
				</view>
			</view>
		</block>		
		<u-safe-bottom></u-safe-bottom>
	</w-container>
</template>

<script>
	import lotteryBox from './components/lotteryBox.vue';
	import lotteryBoxNew from './components/lotteryBoxNew.vue';
	
	import {
		lotteryInfoApi
	} from '@/api/lottery/index.js';
	export default {
		components: {
			lotteryBox,
			lotteryBoxNew
		},
		data() {
			return {
				id: 0,
				loading: true,
				info: {
					remaining: 0, // 剩余抽奖次数
					collection_json: [] // 藏品列表
				}
			};
		},
		computed: {
			getBgStyle() {
				// let url = this.$ossUrl + this.info.image2;
				let url = this.$ossUrl + '/static/cj/draw-bg.png'
				console.log(url,'234234');
				// return `background-image:url(${url})`
			}
		},
		onLoad({
			id
		}) {
			id && (this.id = id);
		},
		onShow() {
			this.getDetails()
		},
		methods: {
			// 获取抽奖详情
			getDetails() {
				lotteryInfoApi({
					id: this.id
				}).then(res => {
					this.loading = false;
					this.info = res.data;
					uni.setStorageSync('lotteryRule', res.data.content)
				}).catch(() => {
					setTimeout(() => {
						this.backPage()
					}, 1500)
				})
			},
			// 水晶类型
			crystal() {
				let {
					crystal
				} = this.info;
				switch (true) {
					case crystal == '10':
						return {
							icon: 'hsj', name: '黄'
						}
						break;
					case crystal == '20':
						return {
							icon: 'zsj', name: '紫'
						}
						break;
					case crystal == '30':
						return {
							icon: 'lsj', name: '蓝'
						}
						break;
				}
			}
		}
	}
</script>
<style>
	page {
		background: #186BFD;
	}
</style>
<style lang="scss">
	#container {
		// background-color: $main-bg-color;
		background-size: 100% auto;
		background-repeat: no-repeat;
		position: relative;	
		.rule-box {
			position: absolute;
			right: 0;
			top: 20vh;
			width: 64rpx;
			height: 176rpx;
			z-index: 9999;
		}

		>.line {
			width: 100%;
			// height: 30rpx;
			// background-color: #1BDFE9;
		}

		.list {
			width: 100%;
			min-height: 500rpx;
			padding: 36rpx;
			box-sizing: border-box;
			background: linear-gradient( 90deg, #FFE9F5 0%, #DEFDF5 100%);

			>.title {
				width: 100%;
				height: 33px;
				background: #E7ECFF;
				border-radius: 16rpx;
				@extend .flex-center, .font-size-12, .font-color-textPrimary, .mb-18;

				>text {
					margin-left: 8rpx;
					color: $theme-color;
				}
			}

			>.con {
				width: 100%;
				@extend .flex, .flex-w, .flex-js-sb;

				.item {
					// @extend .br-12;
					// background-color: #fff;

					>.img {
						// background: linear-gradient(-50deg,rgba(255, 181, 69, 1), rgba(245, 168, 113, 1));

						border-radius: 16rpx 16rpx 16rpx 16rpx;
						border: 4rpx solid $theme-color;
						opacity: 1;
						border-radius: 24rpx 24rpx 24rpx 24rpx;
						border: 4rpx solid;
						// border-image: radial-gradient(circle, rgba(38, 41, 55, 1), rgba(39, 41, 48, 1)) 4 4;
						position: relative;
						overflow: hidden;

						>.num {
							padding: 0 20rpx;
							height: 40rpx;
							line-height: 40rpx;
							position: absolute;
							right: -2rpx;
							bottom: -2rpx;
							background-image: url($IMG_URL+'/static/cj/18.png');
							background-size: 100% 100%;
							font-size: 24rpx;
							color: #fff;
						}
					}

					>text {
						display: inline-block;
						width: 100%;
						color: #666;
						// text-align: center;
					}
				}

			}
		}
	}
	.else-actoon-btn {
		width: 152rpx;
		height: 56rpx;
		background: rgba(41,41,41,0.8);
		border-radius: 28rpx 28rpx 28rpx 28rpx;
		font-family: Source Han Sans CN VF, Source Han Sans CN VF;
		font-weight: 500;
		font-size: 28rpx;
		color: #FFFFFF;
	}
</style>